

import 'package:demo/about.dart';
import 'package:demo/layout.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  Permission.camera.request();
  Permission.mediaLibrary.request();
  Permission.videos.request();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      builder:(context,child){
          return MediaQuery(data:MediaQuery.of(context).copyWith(textScaleFactor:1.0), child:child!);
      },

      theme: ThemeData(
        backgroundColor:const Color.fromARGB(255, 255, 255, 1),
        primarySwatch: Colors.blue,
        // highlightColor:Color.fromRGBO(0, 0, 0, 0), //去除点击阴影
        // splashColor:Color.fromRGBO(0, 0, 0, 0),  //去除点击阴影
      ),
      routes:{
         "/home":(context)=>const MyHomePage(title:"Home"),
         "/about":(context)=> const About()
      },
      initialRoute:"/home",
      //home: const MyHomePage(title: 'Home'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});



  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {

      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
        shadowColor:Colors.transparent,
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            TextButton(onPressed:()=>{
                Navigator.pushNamed(context,"/about")
            }, child:const Text("关于")),
            TextButton(onPressed:()=>{
              Navigator.push(context, MaterialPageRoute(builder:(context)=>const Layout()))
            }, child:const Text("布局"))
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
